import { Modal } from "antd";
import { useEffect } from "react";
import CloudTable from "@/component/CloudTable";

/**
 * save 保存关联关系
 * tableProps 表格属性
 * @returns 
 */
const TableModal = ({ props = {} }) => {

    // 表格属性
    const { title, width, visible, row, onReload, isOpenDialog, resetSelected } = props;

    const onCancelHandler = () => {
        resetSelected([]);
        isOpenDialog();
    }
    
    useEffect(() => {
        if (visible) {
            onReload(row);
        }
    }, [visible]);

    return (
        <Modal
            width={width + 100}
            title={title}
            open={visible}
            footer={null}
            onCancel={onCancelHandler}
            bodyProps={{ style: { padding: '0 10px 10px' } }}
        >
            <CloudTable props={props} />
        </Modal>
    );
}

export default TableModal;